﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Xml;
using System.Data;

using Gift.Model;
using Gift.DAL;
using Gift.WebApp;

using System.Collections;

public partial class cn_UserControl_module_navigation : System.Web.UI.UserControl
{
    readonly BasePage theBasePage = new BasePage();
    protected string xmlPath = "/cn/xml/home.xml";
    // Methods
    protected StringBuilder ModuleNavigationBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            DataRow current;
            XmlElement element;
            int num5;
            IEnumerator enumerator;
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.xmlPath));
            builder.AppendLine("<div class=\"new_por\">");
            builder.AppendLine(" <div class=\"title\">");
            builder.AppendLine("<div class=\"pro_menu\">");
            DataTable table = BaseFactory.theCategory.GetCategoryByNavigationTypeAndIsShow(1, 1, theBasePage.CompanyId);
            int num = 0;
            enumerator = table.Rows.GetEnumerator();

            while (enumerator.MoveNext())
            {
                current = (DataRow)enumerator.Current;
                builder.AppendLine(string.Concat(new object[] { "", (num == 0) ? "" : " | ", "<a href=\"/cn/channel.html?cid=", current["id"], "\">", current["categoryName"], "</a>" }));
                num = 1;
            }

            builder.AppendLine("</div>");
            builder.AppendLine("<p><span class=\"t_name_1\">新品上市</span><span class=\"t_name_2\">NEW</span></p>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"info\">");
            builder.AppendLine("<div class=\"info_img_link\">");
            XmlNodeList childNodes = document.SelectSingleNode("home_ad/new/left").ChildNodes;
            foreach (XmlNode node in childNodes)
            {
                element = (XmlElement)node;
                builder.AppendLine("<a href=\"" + element.GetAttribute("url") + "\" title=\"" + element.GetAttribute("alt")  + "\"  target=\"_blank\"><img src=\"" + element.GetAttribute("src") + "\" alt=\"" + element.GetAttribute("alt") + "\" /></a>");
            }
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"info_link\">");
            string articleTypeId = BaseFactory.theArticleType.GetIdByTypeNameAndParentIdAndIsShow("促销活动", BaseFactory.theArticleType.GetIdByTypeNameAndParentIdAndIsShow("资讯中心", "00000000-0000-0000-0000-000000000000", 1), 1);
            DataTable atricleByArticleTypeIdAndTop = BaseFactory.theArticle.GetAtricleByArticleTypeIdAndTop(articleTypeId, 2);
            builder.AppendLine("<ul>");
            enumerator = atricleByArticleTypeIdAndTop.Rows.GetEnumerator();

            while (enumerator.MoveNext())
            {
                current = (DataRow)enumerator.Current;
                builder.AppendLine(string.Concat(new object[] { "<li><a href=\"/cn/news_center/news_detail.html?id=", current["id"], "\" title=\"", current["articleTilte"], "\">- ", (current["articleTilte"].ToString().Length > 15) ? (current["articleTilte"].ToString().Substring(0, 15) + "...") : current["articleTilte"], "</a></li>" }));
            }

            builder.AppendLine("</ul>");
            XmlNodeList list2 = document.SelectSingleNode("home_ad/new/right").ChildNodes;
            foreach (XmlNode node in list2)
            {
                element = (XmlElement)node;
                builder.AppendLine("<a href=\"" + element.GetAttribute("url") + "\" target=\"_blank\"><img src=\"" + element.GetAttribute("src") + "\" alt=\"" + element.GetAttribute("alt") + "\" /></a>");
            }
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"clear\"></div>");
            builder.AppendLine("<div class=\"info_list_new\">");
            builder.AppendLine("<ul>");
            DataTable table3 = BaseFactory.theGoods.GetGoodsByIsNewAndIsShelvesAndTop(1, 1, 8);
            enumerator = table3.Rows.GetEnumerator();

            while (enumerator.MoveNext())
            {
                current = (DataRow)enumerator.Current;
                builder.AppendLine("<li>");
                builder.AppendLine(string.Concat(new object[] { "<a href=\"/cn/goods.html?id=", current["id"], "\" title=\"", current["goodsName"], "\" name=\"#hoverinfo", current["id"], "\" class=\"pro_img\"><img alt=\"", current["imgAlt"], "\" src=\"", current["thumbImg"], "\" /></a>" }));
                builder.AppendLine(string.Concat(new object[] { "<p title=\"", current["goodsName"], "\"><a href=\"/cn/goods.html?id=", current["id"], "\" title=\"", current["goodsName"], "\">", (current["goodsName"].ToString().Length > 8) ? (current["goodsName"].ToString().Substring(0, 8) + "...") : current["goodsName"], "</a><span>市场价", string.Format("{0:C}", Convert.ToDecimal(current["marketPrice"])), "</span><em>会员价：<strong>", string.Format("{0:C}", Convert.ToDecimal(current["salePrice"])), "</strong></em></p>" }));
                builder.AppendLine(string.Concat(new object[] { "<div id=\"hoverinfo", current["id"], "\" style=\"display: none;\"><img src=\"", current["thumbImg"], "\" alt=\"", current["goodsName"], "\" /><p><strong>", current["goodsName"], "</strong> <span>产品编号:", current["goodsNo"], "</span> <span>会员价：<em>", string.Format("{0:C}", Convert.ToDecimal(current["salePrice"])), "</em></span><span><del>市场价", string.Format("{0:C}", Convert.ToDecimal(current["marketPrice"])), "</del></span></p></div>" }));
                builder.AppendLine("</li>");
            }

            builder.AppendLine("</ul>");
            builder.AppendLine("<div class=\"clear\"></div>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            DataTable table4 = BaseFactory.theCategory.GetCategoryByNavigationTypeAndIsShow(2, 1, theBasePage.CompanyId);
            builder.AppendLine("<div class=\"new_por sales\">");
            builder.AppendLine("<div class=\"info\">");
            builder.AppendLine("<div class=\"promotion_img_link\">");
            builder.AppendLine("<div class=\"title\">");
            builder.AppendLine("<div class=\"pro_menu\">");
            int num2 = 0;
            int num3 = 0;
            enumerator = table4.Rows.GetEnumerator();

            while (enumerator.MoveNext())
            {
                current = (DataRow)enumerator.Current;
                if (num3 < 6)
                {
                    builder.AppendLine(string.Concat(new object[] { (num2 == 1) ? " | " : "", "<a href=\"/cn/promotion_goods_list.html?cid=", current["id"], "\">", current["categoryName"], "</a>" }));
                    num2 = 1;
                    num3++;
                }
            }

            builder.AppendLine("</div>");
            builder.AppendLine("<p><span class=\"t_name_1\">促销专区</span><span class=\"t_name_2\">PROMOTION</span></p>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"box_promotion\">");
            builder.AppendLine("<div class=\"box_promotion_left\">");
            builder.AppendLine("<ul id=\"tabMenu\">");
            num2 = 0;
            num3 = 0;
            enumerator = table4.Rows.GetEnumerator();

            while (enumerator.MoveNext())
            {
                current = (DataRow)enumerator.Current;
                if (num3 < 6)
                {
                    builder.AppendLine(string.Concat(new object[] { "<li ", (num2 == 0) ? "class=\"comments selected\"" : "class=\"comments\"", "><strong>", current["categoryName"], "促销</strong></li>" }));
                    num2 = 1;
                    num3++;
                }
            }

            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"boxBody\">");
            int num4 = 1;
            enumerator = table4.Rows.GetEnumerator();

            while (enumerator.MoveNext())
            {
                current = (DataRow)enumerator.Current;
                builder.AppendLine(string.Concat(new object[] { "<div id=\"comments", num4, "\" ", (num4 == 1) ? "class=\"show\"" : "", ">" }));
                builder.AppendLine("<ul class=\"l_two\">");
                DataTable table5 = BaseFactory.theGoods.GetGoodsByCategoryAndIsShelvesAndIsPromoteAndTop(current["id"].ToString(), 1, 10, 1);
                foreach (DataRow row2 in table5.Rows)
                {
                    builder.AppendLine("<li>");
                    builder.AppendLine(string.Concat(new object[] { "<a href=\"/cn/goods.html?id=", row2["id"], "\" title=\"", row2["imgAlt"], "\"><img style=\"width:132px; height:132px;\" src=\"", row2["thumbImg"], "\" alt=\"", row2["imgAlt"], "\" /></a>" }));
                    builder.AppendLine(string.Concat(new object[] { "<p align=\"center\"><a href=\"/cn/goods.html?id=", row2["id"], "\" title=\"", row2["goodsName"], "\">", (row2["goodsName"].ToString().Length > 8) ? (row2["goodsName"].ToString().Substring(0, 8) + "...") : row2["goodsName"].ToString(), "</a><br /><span class=\"red\">促销价", string.Format("{0:C}", Convert.ToDecimal(row2["salePrice"])), "</span></p>" }));
                    builder.AppendLine("</li>");
                }
                builder.AppendLine("</ul>");
                builder.AppendLine("</div>");
                num4++;
            }

            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            
            DataTable table7 = BaseFactory.theCategory.GetCategoryByNavigationTypeAndIsShow(3, 1, theBasePage.CompanyId);
            int num6 = 0;
            for (num5 = 0; num5 < table7.Rows.Count; num5++)
            {
                current = table7.Rows[num5];
                DataTable table8 = BaseFactory.theGoods.GetGoodsByCategoryAndIsShelvesAndTop(current["id"].ToString(), 1, 10);
                if (table8.Rows.Count > 0)
                {
                    if (num6 == 2)
                    {
                        XmlElement element2 = (XmlElement)document.SelectSingleNode("home_ad/middle");
                        builder.AppendLine("<div class=\"banner_02\"><a href=\"" + element2.GetAttribute("url") + "\"><img src=\"" + element2.GetAttribute("src") + "\" alt=\"" + element2.GetAttribute("alt") + "\" /></a></div>");
                    }
                    builder.AppendLine("<div class=\"new_por\">");
                    builder.AppendLine("<div class=\"title\">");
                    builder.AppendLine("<div class=\"pro_menu\"><a href=\"/cn/goods_list.html?cid=" + current["categoryIdentity"] + "\" title=\"查看更多\">查看更多>>></a></div>");
                    builder.AppendLine("<p><span class=\"t_name_1\">" + current["categoryName"] + "</span></p>");
                    builder.AppendLine("</div>");
                    builder.AppendLine("<div class=\"info\">");
                    XmlElement element3 = (XmlElement)document.SelectSingleNode("home_ad/category_ad").ChildNodes[num5];
                    builder.AppendLine("<a href=\"" + element3.GetAttribute("url") + "\" class=\"banner_01\"><img src=\"" + element3.GetAttribute("src") + "\" alt=\"" + element3.GetAttribute("alt") + "\" /></a>");
                    builder.AppendLine("<div class=\"info_list\">");
                    builder.AppendLine("<ul>");
                    foreach (DataRow row4 in table8.Rows)
                    {
                        builder.AppendLine("<li>");
                        builder.AppendLine(string.Concat(new object[] { "<a href=\"/cn/goods.html?id=", row4["id"], "\" name=\"#hoverinfo", row4["id"], "\" class=\"pro_img\"><img alt=\"", row4["imgAlt"], "\" src=\"", row4["thumbImg"], "\" /></a>" }));
                        builder.AppendLine(string.Concat(new object[] { "<p><a href=\"/cn/goods.html?id=", row4["id"], "\">", (row4["goodsName"].ToString().Length > 8) ? (row4["goodsName"].ToString().Substring(0, 8) + "...") : row4["goodsName"], "</a><span>市场价", string.Format("{0:C}", Convert.ToDecimal(row4["marketPrice"])), "</span><em>会员价：<strong>", string.Format("{0:C}", Convert.ToDecimal(row4["salePrice"])), "</strong></em></p>" }));
                        builder.AppendLine(string.Concat(new object[] { "<div id=\"hoverinfo", row4["id"], "\" style=\"display: none;\"><img src=\"", row4["thumbImg"], "\" alt=\"", row4["goodsName"], "\" /><p><strong>", row4["goodsName"], "</strong> <span>产品编号:", row4["goodsNo"], "</span> <span>会员价：<em>", string.Format("{0:C}", Convert.ToDecimal(row4["salePrice"])), "</em></span><span><del>市场价", string.Format("{0:C}", Convert.ToDecimal(row4["marketPrice"])), "</del></span></p></div>" }));
                        builder.AppendLine("</li>");
                    }
                    builder.AppendLine("</ul>");
                    builder.AppendLine("<div class=\"clear\"></div>");
                    builder.AppendLine("</div>");
                    builder.AppendLine("</div>");
                    builder.AppendLine("</div>");
                    num6++;
                }
            }
        }
        catch
        {
        }
        return builder;
    }

  public  string BindPointsForList()
    {
      StringBuilder    builder = new StringBuilder();

      builder.AppendLine(" <div class=\"title\">");
        builder.AppendLine(" <div class=\"pro_menu\">");
      builder.AppendLine("<a href=\"/cn/points_for_list.html\" target=\"_blank\">查看更多>>></a>");
        builder.AppendLine("</div>");
      builder.AppendLine("  <p><span class=\"t_name_1\">积分兑换</span><span class=\"t_name_2\">EXCHANGE</span></p>");
      builder.AppendLine(" </div>");
           
      builder.AppendLine("<div class=\"points_for\">");
        builder.AppendLine("<ul>");
        DataTable pointsForByRows = BaseFactory.thePointsFor.GetPointsForByRows(9);
        for (int num5 = 0; num5 < pointsForByRows.Rows.Count; num5++)
        {
            DataRow row3 = pointsForByRows.Rows[num5];
          
            builder.AppendLine("<li class=\"list\" >" );
            builder.AppendLine(string.Concat(new object[] { "<img src=\"", row3["image"], "\" onMouseOver=\"this.className='htmer_img'\" onMouseOut=\"this.className='none'\" alt=\"", row3["name"], "\" />" }));
            builder.AppendLine("<span>" + row3["name"] + "</span>");

            builder.AppendLine("<div><div class='points_left'>所需积分：<b>" + row3["exchangePoints"] + "</b></div>");
            builder.AppendFormat("<div class='points_right'><a href='points_for.html?id={0}' style=\"cursor:pointer;\" >立即兑换</a></div></div>", row3["id"]);
            builder.AppendLine("</li>");
        }
        builder.AppendLine("</ul>");
        builder.AppendLine("</div>");
        builder.AppendLine("<div class=\"clear\"></div>");


        return builder.ToString();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

}